import {MiddlewareConsumer, Module, NestModule} from '@nestjs/common'
import {AppController} from './app.controller'
import {AccountController} from "./account.controller";
import {AccountMiddleware} from './middleware/account.middleware'
import {GlobalController} from './global.controller'
import {AccountGuard} from "./guards/account.guard";
import {APP_GUARD} from '@nestjs/core'

@Module({
    controllers: [
        AppController,
        AccountController,
        GlobalController
    ],
    providers: [
        {                           //全局守卫
            provide: APP_GUARD,
            useClass: AccountGuard
        }
    ]
})
export class AppModule implements NestModule {
    configure(consumer: MiddlewareConsumer): any {
        consumer.apply(AccountMiddleware).forRoutes(AccountController, GlobalController)
    }
}
